{$CLEO .CS}

//-------------MAIN---------------
thread 'SIT2' 
:spawn_boat_loop
while true
    repeat
    wait 0
    until if Player.Defined(0)
    if Actor.Driving($PLAYER_ACTOR)
    then 
        if 0449:   actor $PLAYER_ACTOR in_a_car
        then //0acd: "1" 100
            0@ = Actor.CurrentCar($PLAYER_ACTOR)
            1@ = car.Model(0@)
            02E3: 9@ = car 0@ speed 
            
                if 881E:   not model 1@ boat
                then //0acd: "2" 100
                    if 02BF:   car 0@ sunk 
                    then //0acd: "3" 100
                        goto @spawn_boats
                        while 04AD:   actor $PLAYER_ACTOR in_water 
                             wait 0
                        end
                    end
                end
            
        end
    else 
        if 04AD:   actor $PLAYER_ACTOR in_water 
        then goto @spawn_boats
             while 04AD:   actor $PLAYER_ACTOR in_water 
                 wait 0
             end
        end
    end
end


:spawn_boats
                model.Load(#JETMAX)                                                                                                                    
                038B: load_requested_models                                                                                                             
                while not model.Available(#JETMAX)
                    wait 0                                                                                                     
                    goto @spawn_boat_loop                                                                                                                
                end                                                                                                                                     
                if 0449:   actor $PLAYER_ACTOR in_a_car                                                                                                 
                then 29@ = actor.CurrentCar($PLAYER_ACTOR)                                                                                              
                                                                                                                  
                    if 056E:   car 29@ defined                                                                                                          
                    then                                                                                                                                
                        09C9: disembark_actor $player_actor from_car 29@ and_freeze_actor_position                                                      
                        0918: set_car 29@ engine_operation 0                                                                                            
                        car.RemoveReferences(29@)                                                                                                       
                        car.Destroy(29@)                                                                                                                
                    end
                end                                                                                                                                    
                04C4: store_coords_to 3@ 4@ 5@ from_actor $player_actor with_offset 0.0 0.0 -1.0                        
                064B: 6@ = create_particle "EXPLOSION_MEDIUM" at 3@ 4@ 5@ type 1 
                064F: remove_references_to_particle 6@
                29@ = car.Create(#JETMAX, 3@, 4@, 5@)                                                                        
                6@ = actor.Angle($player_actor)                                                                                                
                car.Angle(29@) = 6@                                                                                                            
                model.Destroy(#JETMAX)                                                                                                             
                0878: set_car 29@ dirt_level 0.0                                                                                                    
                0918: set_car 29@ engine_operation 1                                                                                                
                036A: put_actor $player_actor in_car 29@
                Car.SetSpeedInstantly(29@, 9@)
goto @spawn_boat_loop                